<template>
  <yt-page title="先期处置">
    <yt-group :group="false" :searchApi="searchApi">
      <div slot-scope="instruction">
        <yt-cell :label="instruction.title" border="none" labelWidth="70%" isLink @click="onClickInstruction(instruction)">
          <span class="c-blue">指令记录</span>
        </yt-cell>
        <yt-textarea type="column" v-model="instruction.context" disabled></yt-textarea>
        <yt-split></yt-split>
      </div>
    </yt-group>
  </yt-page>
</template>

<script>
import { commonApi } from '@/common/api/commonApi.js'
import { InstructionRecords } from './router.js'

export default {
  data() {
    return {
      emergencyObj: {},
      searchApi: async ({ skip, limit }) => {
        let emergencyObj = await commonApi.searchById(
          'yj_emergency_information',
          this.$route.query.id
        ) // 当前事故信息
        let plan = await commonApi.searchById(
          'yj_special_plan',
          emergencyObj.reservePlan
        ) // 当前事故选中预案信息
        let instructions = plan.list
        this.emergencyObj = emergencyObj
        return instructions
      }
    }
  },
  methods: {
    onClickInstruction(instructions) {
      this.$router.$push({
        path: InstructionRecords.path,
        query: {
          index: instructions._index,
          programmeId: this.emergencyObj.reservePlan,
          accidentId: this.emergencyObj.id
        }
      })
    }
  }
}
</script>
